package com.yiduo.outpost.core.web;

import com.yiduo.outpost.core.web.exception.WebFluxErrorAttributes;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yanwen
 */
@Configuration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
@AutoConfigureBefore(ErrorWebFluxAutoConfiguration.class)
public class WebFluxAutoConfiguration {

    @Bean
    public WebFluxErrorAttributes errorAttributes(MessageSource messageSource) {
        return new WebFluxErrorAttributes(messageSource);
    }
}
